import 'package:flutter/material.dart';
import 'package:module_home/model/ISSDataEntity.dart';

class MenuDataItem extends StatefulWidget {
  final ChildList childList;

  const MenuDataItem({Key key, this.childList}) : super(key: key);

  @override
  _MenuDataItemState createState() => _MenuDataItemState();
}

class _MenuDataItemState extends State<MenuDataItem> {
  @override
  Widget build(BuildContext context) {
    return Container(
        margin: EdgeInsets.all(10),
        height: 50,
        decoration: new BoxDecoration(
            border: new Border.all(color: Colors.grey, width: 0.5),
            color: Colors.grey.shade100,
            borderRadius: new BorderRadius.circular((5.0))),
        child: Stack(
          children: [
            Container(
              alignment: Alignment.center,
              child: Text(
                widget.childList.name,
                style: TextStyle(color: Colors.black, fontSize: 15),
              ),
            ),
            Visibility(
                visible: widget.childList.issValue > 0,
                child: Positioned(
                  right: 0.0,
                  top: 0.0,
                  child: _buildImage(widget.childList.issValue),
                ))
          ],
        ));
  }
}

Image _buildImage(int issValue) {
  switch (issValue) {
    case 1:
      return Image.asset("images/compute_icon_sign1.png",
          height: 20, width: 20);
    case 2:
      return Image.asset("images/compute_icon_sign2.png",
          height: 20, width: 20);
    case 3:
      return Image.asset("images/compute_icon_sign3.png",
          height: 20, width: 20);
    case 4:
      return Image.asset("images/compute_icon_sign4.png",
          height: 20, width: 20);
    case 5:
      return Image.asset("images/compute_icon_sign5.png",
          height: 20, width: 20);
    case 6:
      return Image.asset("images/compute_icon_sign6.png",
          height: 20, width: 20);
    default:
      return Image.asset("");
  }
}
